package com.guomao.democ;

public class ThreadDemo {


    public static void main(String[] args) {

//        获取当前正在执行cpu的线程对象
//        Thread t = Thread.currentThread();

//        String name = t.getName();
//        System.out.println(name);

//        t.setName("ThreadDemo");
//        System.out.println(10/0);

//        for (int i = 201; i <= 800; i++) {
//            System.out.println(i);
//        }

//        shownum();

//        java虚拟的线程调度机制 抢占式 每个线程都会抢占cpu时间片
//        MyRunImpl thread1 = new MyRunImpl();
//        MyRunImpl thread2 = new MyRunImpl();

//        thread1.setName("myThread-t1");
//        thread2.setName("myThread-t2");
//        thread1.run();
//        thread1.start();//thread-0
//        thread2.start();


        MyThread mt1 = new MyThread("mythread1");
        MyThread mt2 = new MyThread("mythread2");

        mt1.start();
        mt2.start();

    }

    public static void shownum() {
        for (int i = 1; i <= 1000; i++) {
            System.out.println(i);
        }
    }
}
